using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;

public class SkeleEnemy : Enemy
{
    public CapsuleCollider2D cc {  get; private set; }
    public SkeleIdleState idleState { get; private set; }
    public SkeleMoveState moveState { get; private set; }
    public SkeleBatttleState battleState { get; private set; }
    public SkeleAttackState attackState { get; private set; }
    public SkeleStunnedState stunnedState { get; private set; }
    public SkeleDeadState deadState { get; private set; }
    protected override void Awake()
    {
        base.Awake();
        
        idleState = new SkeleIdleState(this, stateMachine, "Idle");
        moveState = new SkeleMoveState(this, stateMachine, "Move");
        battleState = new SkeleBatttleState(this, stateMachine, "Move");
        attackState = new SkeleAttackState(this, stateMachine, "Attack");
        stunnedState = new SkeleStunnedState(this, stateMachine, "Stunned");
        deadState = new SkeleDeadState(this, stateMachine, "Dead");
        cc = GetComponent<CapsuleCollider2D>();
    }

    protected override void Start()
    {
        base.Start();
        stateMachine.Init(idleState);
    }

    protected override void Update()
    {
        base.Update();
        
    }

    public override bool CanBeStunned()
    {
        if (base.CanBeStunned()) 
        {
            stateMachine.ChangeState(stunnedState);
            return true;
        }
        return false;
    }

    public override void Die()
    {
        if (counterImg.activeSelf)
        {
            CloseCounterWindow();
        }
        stateMachine.ChangeState(deadState);
    }
}
